from django.conf.urls import url

from meiduo_admin.views import skus, orders, perms, brands
from .views import channels
from .views import statistical
from .views import users

urlpatterns = [
    url(r'^authorizations/$', users.AdminAuthorizeView.as_view()),
    url(r'^statistical/total_count/$', statistical.UserTotalCountView.as_view()),
    url(r'^statistical/day_increment/$', statistical.UserDayIncrementView.as_view()),
    url(r'^statistical/day_active/$', statistical.UserDayActiveView.as_view()),
    url(r'^statistical/day_orders/$', statistical.UserDayOrderView.as_view()),
    url(r'^statistical/month_increment/$', statistical.UserMouthCountView.as_view()),
    url(r'^statistical/goods_day_views/$', statistical.GoodsDayView.as_view()),
    url(r'^users/$', users.UserInfoView.as_view()),
    # url(r'^goods/channels/$', channels.ChannelViewSet.as_view({
    #     'get': 'list',
    #     'post': 'create'
    # })),
    url(r'^goods/channel_types/$', channels.ChannelTypeView.as_view()),
    url(r'^goods/categories/$', channels.ChannelCategoriesView.as_view()),
    url(r'^skus/simple/$', skus.SKUSimpleView.as_view()),

    # SKU管理
    url(r'^goods/simple/$', skus.SPUSimpleView.as_view()),
    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SPUSpecView.as_view()),

    # 权限管理
    url(r'^permission/content_types/$', perms.PermissionViewSet.as_view({
        'get': 'content_types'
    })),
    # 用户组管理
    url(r'^permission/simple/$', perms.GroupViewSet.as_view({
        'get': 'simple'
    })),
    # 管理员管理
    url(r'^permission/groups/simple/$', perms.AdminViewSet.as_view({
        'get': 'simple'
    })),
    # 规格管理
    url(r'^goods/simple/$', brands.SpecsViewSet.as_view({
        'get': 'simple'
    })),
    # 规格选项管理
    url(r'^goods/specs/simple/$', brands.OptionViewSet.as_view({
        'get': 'simple'
    })),
    # SPU管理
    url(r'^goods/brands/simple/$', brands.SPUViewSet.as_view({
        'get': 'simple'
    })),
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', brands.SPUViewSet.as_view({
        'get': 'category_2_3'
    })),
    url(r'^goods/channel/categories/$', brands.SPUViewSet.as_view({
        'get': 'category_1'
    })),
]

from rest_framework.routers import DefaultRouter

# 频道管理
router = DefaultRouter()
router.register('goods/channels', channels.ChannelViewSet, base_name='channels')
urlpatterns += router.urls

# 图片管理
router = DefaultRouter()
router.register('skus/images', skus.SKUImageViewSet, base_name='images')
urlpatterns += router.urls

# SKU管理
router = DefaultRouter()
router.register('skus', skus.SKUViewSet, base_name='skus')
urlpatterns += router.urls

# 订单管理
router = DefaultRouter()
router.register('orders', orders.OrderViewSet, base_name='orders')
urlpatterns += router.urls

# 权限管理
router = DefaultRouter()
router.register('permission/perms', perms.PermissionViewSet, base_name='perms')
urlpatterns += router.urls

# 用户组管理
router = DefaultRouter()
router.register('permission/groups', perms.GroupViewSet, base_name='groups')
urlpatterns += router.urls

# 管理员管理
router = DefaultRouter()
router.register('permission/admins', perms.AdminViewSet, base_name='admins')
urlpatterns += router.urls

# 品牌管理
router = DefaultRouter()
router.register('goods/brands', brands.BrandViewSet, base_name='brands')
urlpatterns += router.urls

# 规格管理
router = DefaultRouter()
router.register('goods/specs', brands.SpecsViewSet, base_name='specs')
urlpatterns += router.urls

# 规格选项管理
router = DefaultRouter()
router.register('specs/options', brands.OptionViewSet, base_name='options')
urlpatterns += router.urls

# SPU管理
router = DefaultRouter()
router.register('goods', brands.SPUViewSet, base_name='goods')
urlpatterns += router.urls
